""" Plot band structure from a VASP-EIGENCAR file.
GHB, 20180208.
"""
import matplotlib.pyplot as plt
from utils_vasp.band import get_band

# Read data. This function requires three files (POSCAR, KPOINTS, EIGENVAL)
# in the current directory.
dist_c, band_e, dist_l = get_band(E_fermi=1.0)

# If you wonder how many bands there are in the band structure
#print("Number of bands:", len(band_e))

# Plot the band structure.
F = plt.figure(figsize=(4,3))
for i in range(len(band_e)):
    plt.plot(dist_c, band_e[i])

plt.ylabel(r"$E-E_f$ (eV)")       # set label for y-axis
plt.xlim(dist_c[0], dist_c[-1])   # set range of x-axis

# Show labels for the node k-points
labels = [r"$\Gamma$", r"$M$", r"$K$", r"$\Gamma$",
          r"$A$",      r"$L$", r"$H$", r"$A$/$M$",
          r"$L$/$K$",  r"$H$"]
plt.xticks(dist_l, labels)

# Show vertical lines for the node k-points
for x in dist_l:
    plt.axvline(x, linewidth=0.5)

# Adjust, save, and show.
plt.subplots_adjust(left=0.17, right=0.95)
plt.savefig("band1.png", dpi=300)
plt.show()

